﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Windows;


namespace RecommendatioNetwork
{
    [DataContract]
    [Serializable]
    public class Comment
    {
        [DataMember]
        private string typology="default";
        [DataMember]
        private string nameIndex="default";
        [DataMember]
        private string peerName = "default";
        [DataMember]
        private DateTime timestamp;
        [DataMember]
        private string textcomments="default";
        [DataMember]
        public uint Rating { get; set; }
        
        private int numberOfTimeReceived;

        
      
        /// <summary>
        /// Costruttore di Commenti
        /// </summary>
        /// <param name="typology">setta la tipologia del commento</param>
        /// <param name="nameIndex">setta il titolo del commento</param>
        /// <param name="textcomments">setta il testo del commento</param>
        /// <param name="rating">setta il rating del commento</param>
        public Comment(string peer,string typology, string nameIndex, string textcomments,uint rating)
        {
            this.typology = typology;
            this.nameIndex = nameIndex;
            this.peerName = peer;
            this.timestamp = DateTime.Now;
            this.textcomments = textcomments;
            Rating = rating;
        }
        /// <summary>
        /// Proprietà che la tipologia del commento
        /// </summary>
        public string Typology
        {
            get { return typology; }
        }
        /// <summary>
        /// Proprietà che indica il titolo del commento
        /// </summary>
        public string NameIndex
        {
            set { nameIndex = value; }
            get { return nameIndex;  }
        }
        /// <summary>
        /// Proprietà che indica il creatore del commento
        /// </summary>
        public string PeerName 
        {
            get { return peerName;}
        }
        /// <summary>
        /// Proprietà che indica il momento di creazione del commento
        /// </summary>
        public DateTime TimeStamp
        {
            get { return timestamp;}
        }
        /// <summary>
        /// Proprietà che indica il testo di un commento
        /// </summary>
        public string TextComment 
        {
            get { return textcomments; }
        }

        /// <summary>
        /// Proprietà che indica il numero di volte che si è ricevuto lo stesso commento
        /// </summary>
        public int ReplyResponse
        {
            get { return numberOfTimeReceived; }
            set { numberOfTimeReceived = value; }
        }
        /// <summary>
        /// Proprietà che indica un codice univoco che identifica il commento
        /// </summary>
        public string KeyComments {
            get { return "KC" + PeerName + TimeStamp.ToString() + NameIndex; }
        }

        public override bool Equals(object obj)
        {
            Comment c = obj as Comment;
            return string.Equals(this.KeyComments, c.KeyComments, StringComparison.InvariantCultureIgnoreCase);
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override string ToString()
        {
           return "\n"+Typology+"\n"+NameIndex+"\n"+TextComment+"\n"+PeerName;
        }

        
        

        
    }
}
